﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Member_OrderDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["orderId"] != null)
            {
                InitialPage();
            }
        }
    }

    private void InitialPage()
    {
        GoShopping.BLL.Orders.OrderBean ob = new GoShopping.BLL.Orders.OrderBean();
        GoShopping.Model.Order od = ob.GetOneOrder(Convert.ToInt32(Request.QueryString["orderId"]));
        lblReceiver.Text = od.AcceptPeople;
        lblPhone.Text = od.AcceptPeopleTel;
        lblPayed.Text = "0";
        lblOrderDate.Text = od.OrderCreateDate.ToString();
        lblBillWay.Text = od.PayType;
        lblSendWay.Text = od.AcceptType.ToString();
        lblOrderTotal.Text = (od.TotalPrice + od.PostPrice).ToString();
        lblMoney.Text = (od.TotalPrice + od.PostPrice).ToString();
        lblOrderCode.Text = od.OrderCode;
        lblAddr.Text = od.Province + od.City + od.County + od.DetailStreet;
        lblSendRange.Text = od.SendDateRange;

        #region Set Status
        GoShopping.Model.Enumerations.OrderStatusType ost = (GoShopping.Model.Enumerations.OrderStatusType)Enum.Parse(typeof(GoShopping.Model.Enumerations.OrderStatusType), od.State);
        switch (ost)
        {
            case GoShopping.Model.Enumerations.OrderStatusType.PayedFindGoods:
                {
                    SetStatus("您的订单已提交,正在处理中.", "配货中...");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.SendedWaitRecieve:
                {
                    SetStatus("您的订单已处理,发货中.", "发货中...");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.WaitForPay:
                {

                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.Success:
                {
                    SetStatus("交易成功.", "交易成功");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.Canceled:
                {
                    SetStatus("订单已经取消.", "未发货");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.Returning:
                {
                    SetStatus("退货中....", "退货中...");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.ReturnPrdt:
                {
                    SetStatus("退货成功.", "退货成功");
                } break;
            case GoShopping.Model.Enumerations.OrderStatusType.ReturningCash:
                {
                    SetStatus("退款中....", "退款中....");
                } break;
            default: { throw new Exception("没有处理的订单类型或发货状态!"); }
        }
        #endregion

        lvOrderDetail.DataSource = ob.GetOrderEachPrdct(Convert.ToInt32(Request.QueryString["orderId"]));
        lvOrderDetail.DataBind();
    }

    private void SetStatus(string p, string p_2)
    {
        lblOrderStatus.Text = p;
        lblPrdtState.Text = p;
        lblStatus.Text = p_2;
    }
}
